home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / win_q_t / sabdu201.zip / SAMPLE.C < prev    next >
Text File  |  1992-11-01  |  21KB  |  525 lines

  1. #include <Windows.h>
  2.  
  3. #include <IO.h>
  4. #include <StdIO.h>
  5. #include <StdLib.h>
  6. #include <String.h>
  7.  
  8. #include "DDrive.h"
  9. #include "DiskDriv.h"
  10. #include "HandleSt.h"
  11. #include "IOStatus.h"
  12. #include "Sample.h"
  13.  
  14. #ifdef DEBUG
  15. #include "DebugOut.h"
  16. #endif
  17.  
  18. BOOL bCancel ;
  19. BOOL bIdle ;
  20. BOOL bRegisteredClass ;
  21.  
  22. char czIconMessage[64] ;
  23. char czNormalMessage[512] ;
  24.  
  25. FARPROC lpfnHandleStatus ;
  26.  
  27. HINSTANCE hInstance ;
  28.  
  29. HWND hWnd ;
  30.  
  31. UINT nNumberOfDrives ;
  32. UINT nPercentageToColor ;
  33.  
  34. VOID far * pCDebugOut ;
  35.  
  36. VOID far * pCVDriveTest ;
  37.  
  38. VOID far *pCVDrives[26] ;
  39.  
  40. VOID far * pCDiskImage ;
  41.  
  42. VOID far * pCDiskTemporary ;
  43.  
  44. int PASCAL WinMain ( HINSTANCE hCurrentInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, UINT nCmdShow)
  45. {
  46.     MSG msg;
  47.  
  48.     UINT n ;
  49.  
  50. #ifdef DEBUG
  51.     pCDebugOut = DebugOutCreate ( lpCmdLine ) ;
  52. #endif
  53.  
  54.     bRegisteredClass = FALSE ;
  55.     if (!hPrevInstance)
  56.        {
  57.        if (!InitApplication(hCurrentInstance)) return (FALSE);
  58.        bRegisteredClass = TRUE ;
  59.        }
  60.  
  61.     if (!InitInstance(hCurrentInstance, nCmdShow)) return (FALSE);
  62.  
  63.     hInstance = hCurrentInstance ;
  64.  
  65.     while (GetMessage(&msg, NULL, NULL, NULL))
  66.        {
  67.        TranslateMessage(&msg);
  68.        DispatchMessage(&msg);
  69.        }
  70.  
  71.     if ( nNumberOfDrives )
  72.        {
  73.        for ( n=0; n<nNumberOfDrives; n++ ) DDriveDelete ( pCVDrives[n] ) ;
  74.        }
  75.  
  76.     if ( bRegisteredClass ) UnregisterClass ( "SampleWClass", hInstance ) ;
  77.  
  78.     return ( msg.wParam ) ;
  79. }
  80.  
  81. BOOL InitApplication ( HINSTANCE hInstance )
  82. {
  83.     WNDCLASS  wc;
  84.  
  85.     wc.style = NULL;
  86.     wc.lpfnWndProc = MainWndProc;
  87.     wc.cbClsExtra = 0;
  88.     wc.cbWndExtra = 0;
  89.     wc.hInstance = hInstance;
  90.     wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  91.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  92.     wc.hbrBackground = GetStockObject(WHITE_BRUSH); 
  93.     wc.lpszMenuName =  "SampleMenu";
  94.     wc.lpszClassName = "SampleWClass";
  95.     return (RegisterClass(&wc));
  96. }
  97.  
  98. BOOL InitInstance ( HINSTANCE hInstance, UINT nCmdShow )
  99. {
  100.  
  101.     char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
  102.     char czBuffer[256] ;
  103.  
  104.     HMENU hMainMenu ;
  105.     HMENU hPopupMenu ;
  106.  
  107.     int i ;
  108.  
  109.     UINT nMenuID ;
  110.     UINT nPopupMenuID ;
  111.  
  112.     VOID far * pCVDriveTest ;
  113.  
  114.     hWnd = CreateWindow( "SampleWClass", "Sample SABDU001.DLL Application", WS_OVERLAPPEDWINDOW,
  115.                          100, 200, 400, 200,
  116.                          NULL, NULL, hInstance, NULL );
  117.     if (!hWnd) return (FALSE);
  118.  
  119. #ifdef DEBUG
  120.     /* The following will be executed if the program is invoked with /D1 on the command line   */
  121.     /* It will be written to a trace file unless /M1 is also on the command line in which case */
  122.     /* it will be displayed in a MessageBox on the screen                                      */
  123.     wsprintf ( DebugOutczDebugBuffer(), "This is a sample of a debug trace.\n hWnd = %4.4X", hWnd ) ;
  124.     DebugOutOutputIf ( 0x00000001L, DebugOutczDebugBuffer(), "Sample Trace", MB_OK ) ;
  125. #endif
  126.  
  127.     nMenuID = 0 ;
  128.     nNumberOfDrives = 0 ;
  129.     hMainMenu = GetMenu ( hWnd ) ;
  130.     for ( i = 0; i < sizeof(alphabet)/sizeof(alphabet[0])-1 ; i++ )
  131.        {
  132.        pCVDriveTest = (VOID far *) DDriveCreate ( alphabet[i] ) ;
  133.        if (pCVDriveTest==NULL)
  134.           {
  135.           ; /* Memory problems or worse */
  136.           return ( FALSE ) ;
  137.           break ;
  138.           }
  139.        if ((VDriveIsUseable ( pCVDriveTest ))&&(!VDriveIsRemote ( pCVDriveTest ))&&(VDriveIsRemovable ( pCVDriveTest )))
  140.           {
  141.           pCVDrives[nNumberOfDrives] = pCVDriveTest ;
  142.           nNumberOfDrives++ ;
  143.           nMenuID += 100 ;
  144.           hPopupMenu = CreatePopupMenu () ;
  145.           nPopupMenuID = nMenuID ;
  146.           AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, ++nPopupMenuID, "&Compare" ) ;
  147.           nPopupMenuID++ ;
  148.           if ( FD0360 & VDriveType  ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 0&360KB" ) ;
  149.           nPopupMenuID++ ;
  150.           if ( FD0720 & VDriveType  ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 0&720KB" ) ;
  151.           nPopupMenuID++ ;
  152.           if ( FD1200H & VDriveType ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 1&200KB" ) ;
  153.           nPopupMenuID++ ;
  154.           if ( FD1440H & VDriveType ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 1&440KB" ) ;
  155.           nPopupMenuID++ ;
  156.           if ( FD2880H & VDriveType ( pCVDriveTest ) ) AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, nPopupMenuID, "Format 2&880KB" ) ;
  157.           AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, ++nPopupMenuID, "&Read" ) ;
  158.           AppendMenu ( hPopupMenu, MF_ENABLED|MF_STRING, ++nPopupMenuID, "&Write" ) ;
  159.           czBuffer[0] = '&' ;
  160.           czBuffer[1] = VDriveLetter ( pCVDriveTest ) ;
  161.           czBuffer[2] = ':' ;
  162.           czBuffer[3] = '\0' ;
  163.           AppendMenu ( hMainMenu, MF_ENABLED|MF_STRING|MF_POPUP, hPopupMenu, czBuffer ) ;
  164.           }
  165.        else
  166.           {
  167.           DDriveDelete ( pCVDriveTest ) ;
  168.           }
  169.        }
  170.  
  171.     if ( !nNumberOfDrives ) return ( FALSE ) ;
  172.  
  173.     bCancel = FALSE ;
  174.     bIdle   = TRUE ;
  175.  
  176.     pCDiskImage = NULL ;
  177.  
  178.     lpfnHandleStatus = MakeProcInstance ( (FARPROC)HandleStatus, hInstance ) ;
  179.  
  180.     (*(lpfnHANDLESTATUS)lpfnHandleStatus) ( STATUS1_INIT, 0, (UINT)hWnd, (UINT)hInstance, MAKELONG ( TIMER_INTERVAL, 0x0000 ), MAKELONG ( 0x0001, 0x0001 ) ) ;
  181.  
  182.     ShowWindow( hWnd, nCmdShow ) ;
  183.     UpdateWindow( hWnd ) ;
  184.     return ( TRUE ) ;
  185.  
  186. }
  187.  
  188. long FAR PASCAL MainWndProc ( HWND hWnd, UINT nMessage, UINT nParam, LONG lParam )
  189. {
  190.     char  czMessageBuffer[512] ;
  191.  
  192.     HDC     hdc ;
  193.  
  194.     PAINTSTRUCT ps ;
  195.  
  196.     RECT    rClient ;
  197.  
  198.     STMESSAGE far *lpstMessage ;
  199.  
  200.     UINT nAction ;
  201.     UINT nDrive ;
  202.  
  203.     char czApplicationTitle [] = "SAB Diskette Utility" ;
  204.     char czFileName [] = "SABDU.SDU" ;
  205.     char czVersionNumber [] = "2.00" ;
  206.     char czFullPath [_MAX_PATH] ;
  207.  
  208.     switch ( nMessage )
  209.        {
  210.        case WM_PAINT:
  211.           {
  212.           hdc = BeginPaint ( hWnd, &ps ) ;
  213.  
  214.           if (!IsIconic( hWnd ))
  215.              {
  216.              GetClientRect ( hWnd, &rClient ) ;
  217.              if (bIdle)
  218.                 {
  219.                 _fstrcpy ( czMessageBuffer, "Please select an item from the menu" ) ;
  220.                 }
  221.              else
  222.                 {
  223.                 _fstrcpy ( czMessageBuffer, czNormalMessage ) ;
  224.                 }
  225.              DrawText ( hdc, czMessageBuffer, -1, &rClient, DT_CENTER|DT_WORDBREAK ) ;
  226.              }
  227.  
  228.           EndPaint ( hWnd, &ps ) ;
  229.           return ( FALSE ) ;
  230.           break ;
  231.           }
  232.        case USR_ACTIVE:
  233.           {
  234.           bIdle = FALSE ;
  235.  
  236.           lpstMessage = (STMESSAGE far *)lParam ;
  237.  
  238.           if (lpstMessage->pIconMessage)   _fstrcpy ( czIconMessage, lpstMessage->pIconMessage   )  ;
  239.           if (lpstMessage->pNormalMessage) _fstrcpy ( czNormalMessage, lpstMessage->pNormalMessage ) ;
  240.           nPercentageToColor = lpstMessage->nPercentageToColor ;
  241.  
  242.           InvalidateRect ( hWnd, NULL, TRUE ) ;
  243.           UpdateWindow ( hWnd ) ;
  244.  
  245.           return ( !bCancel ) ;
  246.           break ;
  247.           }
  248.        case USR_UPDATE:
  249.           {
  250.           bIdle = FALSE ;
  251.  
  252.           lpstMessage = (STMESSAGE far *)lParam ;
  253.  
  254.           if (lpstMessage->pIconMessage)   _fstrcpy ( czIconMessage, lpstMessage->pIconMessage   )  ;
  255.           if (lpstMessage->pNormalMessage) _fstrcpy ( czNormalMessage, lpstMessage->pNormalMessage ) ;
  256.           nPercentageToColor = lpstMessage->nPercentageToColor ;
  257.  
  258.           InvalidateRect ( hWnd, NULL, FALSE ) ;
  259.           UpdateWindow ( hWnd ) ;
  260.  
  261.           return ( !bCancel ) ;
  262.           break ;
  263.           }
  264.        case USR_INACTIVE:
  265.           {
  266.           bIdle = TRUE ;
  267.           InvalidateRect ( hWnd, NULL, TRUE ) ;
  268.           UpdateWindow ( hWnd ) ;
  269.           return ( !bCancel ) ;
  270.           break ;
  271.           }
  272.        case WM_COMMAND:
  273.           {
  274.  
  275.           if ( nParam==IDCANCEL )
  276.              {
  277.              /*******************************************************/
  278.              /*                                                     */
  279.              /* The user wants to canceL the current activity       */
  280.              /*                                                     */
  281.              /*******************************************************/
  282.              bCancel = TRUE ;
  283.              return ( TRUE ) ;
  284.              }
  285.  
  286.           if (!bIdle)
  287.              {
  288.              /*******************************************************/
  289.              /*                                                     */
  290.              /* The system does not support concurrent activities so*/
  291.              /* ignore requests since we are not idle.              */
  292.              /*                                                     */
  293.              /*******************************************************/
  294.              return ( TRUE ) ;
  295.              }
  296.  
  297.           if ( nParam==IDM_OPEN )
  298.              {
  299.              /*******************************************************/
  300.              /*                                                     */
  301.              /* The user wants to open and read in a diskette image */
  302.              /* file.                                               */
  303.              /* Note: The sample uses the variable czFileName which */
  304.              /* is initialized to "SABDU.SDU".  A file selection    */
  305.              /* dialog would be usefull here.                       */
  306.              /*                                                     */
  307.              /*******************************************************/
  308.              SetWindowText ( hWnd, "Openning" ) ;
  309.              if (_access ( czFileName, 4 ) )
  310.                 {
  311.                 wsprintf ( (LPSTR)czMessageBuffer, (LPCSTR)"Unable to access file: %s", (LPCSTR)_fullpath ( czFullPath, czFileName, _MAX_PATH ) ) ;
  312.                 MessageBox ( hWnd, czMessageBuffer, "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  313.                 return ( TRUE ) ;
  314.                 }
  315.              bCancel = FALSE ;
  316.              pCDiskTemporary = (VOID far *) DiskDriveCreateFile ( czFileName, czApplicationTitle, czVersionNumber, FD0000, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  317.              if (!DiskDriveHasData(pCDiskTemporary)) return ( TRUE ) ;
  318.              if ( pCDiskImage != NULL )
  319.                 {
  320.                 DiskDriveDelete ( pCDiskImage ) ;
  321.                 pCDiskImage = NULL ;
  322.                 }
  323.              pCDiskImage = DiskDriveCreateMemory ( (UINT)0, DiskDriveType ( pCDiskTemporary ), 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  324.              DiskDriveCopy ( pCDiskImage, pCDiskTemporary ) ;
  325.              DiskDriveDelete ( pCDiskTemporary ) ;
  326.              if ( bCancel )
  327.                 {
  328.                 DiskDriveDelete ( pCDiskImage ) ;
  329.                 pCDiskImage = NULL ;
  330.                 }
  331.              bIdle = TRUE ;
  332.              SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  333.              return ( TRUE ) ;
  334.              }
  335.           if ( nParam==IDM_SAVE )
  336.              {
  337.              /*******************************************************/
  338.              /*                                                     */
  339.              /* The user wants to open and write out a diskette     */
  340.              /* image file.                                         */
  341.              /* Note: The sample uses the variable czFileName which */
  342.              /* is initialized to "SABDU.SDU".  A file selection    */
  343.              /* dialog would be usefull here.                       */
  344.              /*                                                     */
  345.              /*******************************************************/
  346.              if ( pCDiskImage==NULL )
  347.                 {
  348.                 MessageBox ( hWnd, "You must first READ in a diskette image before saving", "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  349.                 return ( TRUE ) ;
  350.                 }
  351.              SetWindowText ( hWnd, "Saving" ) ;
  352.              bCancel = FALSE ;
  353.              pCDiskTemporary = (VOID far *) DiskDriveCreateFile ( czFileName, czApplicationTitle, czVersionNumber, DiskDriveType ( pCDiskImage ), DiskDriveUsedCylinders ( pCDiskImage ), (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  354.              if (!DiskDriveType(pCDiskTemporary)) return ( TRUE ) ;
  355.              DiskDriveCopy ( pCDiskTemporary, pCDiskImage ) ;
  356.              DiskDriveDelete ( pCDiskTemporary ) ;
  357.              if (bCancel) remove ( czFileName ) ;
  358.              bIdle = TRUE ;
  359.              SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  360.              return ( TRUE ) ;
  361.              }
  362.  
  363.           if ( nParam==IDM_EXIT )
  364.              {
  365.              /*******************************************************/
  366.              /*                                                     */
  367.              /* The user wants to exit.                             */
  368.              /*                                                     */
  369.              /*******************************************************/
  370.              PostMessage ( hWnd, WM_DESTROY, 0, 0L ) ;
  371.              return ( TRUE ) ;
  372.              }
  373.  
  374.           if ( (nParam>=(UINT)100)&&(nParam<=(UINT)100*(nNumberOfDrives+1) ) )
  375.              {
  376.              /*******************************************************/
  377.              /*                                                     */
  378.              /* The use has selected a diskette drive function.     */
  379.              /* The first digit of the three digit nParam identifies*/
  380.              /* the device.  The next two identify the function.    */
  381.              /*                                                     */
  382.              /*******************************************************/
  383.              nDrive = ( nParam / 100 ) - 1 ;
  384.              nAction = nParam % 100 ;
  385.              bCancel = FALSE ;
  386.              switch ( nAction )
  387.                 {
  388.                 case 1: /* Compare */
  389.                    {
  390.                    if ( pCDiskImage==NULL )
  391.                       {
  392.                       MessageBox ( hWnd, "You must first READ in a diskette image before comparing.", "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  393.                       return ( TRUE ) ;
  394.                       }
  395.                    SetWindowText ( hWnd, "Comparing" ) ;
  396.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], 0, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  397.                    if (!DiskDriveHasData(pCDiskTemporary)) return ( TRUE ) ;
  398.                    DiskDriveCompare ( pCDiskImage, pCDiskTemporary ) ;
  399.                    DiskDriveReset ( pCDiskTemporary ) ;
  400.                    DiskDriveDelete ( pCDiskTemporary ) ;
  401.                    bIdle = TRUE ;
  402.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  403.                    return ( TRUE ) ;
  404.                    break ;
  405.                    }
  406.                 case 2: /* Format  360KB */
  407.                    {
  408.                    SetWindowText ( hWnd, "Formating 0360KB" ) ;
  409.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD0360, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  410.                    DiskDriveFormat ( pCDiskTemporary, "Sample 0360", NULL, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  411.                    DiskDriveReset ( pCDiskTemporary ) ;
  412.                    DiskDriveDelete ( pCDiskTemporary ) ;
  413.                    bIdle = TRUE ;
  414.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  415.                    return ( TRUE ) ;
  416.                    break ;
  417.                    }
  418.                 case 3: /* Format  720KB */
  419.                    {
  420.                    SetWindowText ( hWnd, "Formating 0720KB" ) ;
  421.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD0720, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  422.                    DiskDriveFormat ( pCDiskTemporary, "Sample 0720", NULL, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  423.                    DiskDriveReset ( pCDiskTemporary ) ;
  424.                    DiskDriveDelete ( pCDiskTemporary ) ;
  425.                    bIdle = TRUE ;
  426.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  427.                    return ( TRUE ) ;
  428.                    break ;
  429.                    }
  430.                 case 4: /* Format 1200KB */
  431.                    {
  432.                    SetWindowText ( hWnd, "Formating 1200KB" ) ;
  433.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD1200, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  434.                    DiskDriveFormat ( pCDiskTemporary, "Sample 1200", NULL, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  435.                    DiskDriveReset ( pCDiskTemporary ) ;
  436.                    DiskDriveDelete ( pCDiskTemporary ) ;
  437.                    bIdle = TRUE ;
  438.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  439.                    return ( TRUE ) ;
  440.                    break ;
  441.                    }
  442.                 case 5: /* Format 1440KB */
  443.                    {
  444.                    SetWindowText ( hWnd, "Formating 1440KB" ) ;
  445.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD1440, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  446.                    DiskDriveFormat ( pCDiskTemporary, "Sample 1440", NULL, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  447.                    DiskDriveReset ( pCDiskTemporary ) ;
  448.                    DiskDriveDelete ( pCDiskTemporary ) ;
  449.                    bIdle = TRUE ;
  450.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  451.                    return ( TRUE ) ;
  452.                    break ;
  453.                    }
  454.                 case 6: /* Format 2880KB */
  455.                    {
  456.                    SetWindowText ( hWnd, "Formating 2880KB" ) ;
  457.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD2880, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  458.                    DiskDriveFormat ( pCDiskTemporary, "Sample 2880", NULL, NULL, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  459.                    DiskDriveReset ( pCDiskTemporary ) ;
  460.                    DiskDriveDelete ( pCDiskTemporary ) ;
  461.                    bIdle = TRUE ;
  462.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  463.                    return ( TRUE ) ;
  464.                    break ;
  465.                    }
  466.                 case 7: /* Read */
  467.                    {
  468.                    SetWindowText ( hWnd, "Reading" ) ;
  469.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], FD0000, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  470.                    if (!DiskDriveHasData(pCDiskTemporary)) return ( TRUE ) ;
  471.                    if ( pCDiskImage != NULL )
  472.                       {
  473.                       DiskDriveDelete ( pCDiskImage ) ;
  474.                       pCDiskImage = NULL ;
  475.                       }
  476.                    pCDiskImage = DiskDriveCreateMemory ( (UINT)0, DiskDriveType ( pCDiskTemporary ), 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  477.                    DiskDriveCopy ( pCDiskImage, pCDiskTemporary ) ;
  478.                    DiskDriveReset ( pCDiskTemporary ) ;
  479.                    DiskDriveDelete ( pCDiskTemporary ) ;
  480.                    if ( bCancel )
  481.                       {
  482.                       DiskDriveDelete ( pCDiskImage ) ;
  483.                       pCDiskImage = NULL ;
  484.                       }
  485.                    bIdle = TRUE ;
  486.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  487.                    return ( TRUE ) ;
  488.                    break ;
  489.                    }
  490.                 case 8: /* Write */
  491.                    {
  492.                    if ( pCDiskImage==NULL )
  493.                       {
  494.                       MessageBox ( hWnd, "You must first READ in a diskette image before writting.", "Sample", MB_ICONEXCLAMATION|MB_OK ) ;
  495.                       return ( TRUE ) ;
  496.                       }
  497.                    SetWindowText ( hWnd, "Writing" ) ;
  498.                    pCDiskTemporary = DiskDriveCreateVDrive ( pCVDrives[nDrive], 0, 0, (lpfnHANDLESTATUS) lpfnHandleStatus ) ;
  499.                    DiskDriveCopy ( pCDiskTemporary, pCDiskImage ) ;
  500.                    DiskDriveReset ( pCDiskTemporary ) ;
  501.                    DiskDriveDelete ( pCDiskTemporary ) ;
  502.                    bIdle = TRUE ;
  503.                    SetWindowText ( hWnd, "Sample SABDU001.DLL Application" ) ;
  504.                    return ( TRUE ) ;
  505.                    break ;
  506.                    }
  507.                 }
  508.              }
  509.  
  510.           break ;
  511.           }
  512.        case WM_DESTROY:
  513.           {
  514.           PostQuitMessage( 0 ) ;
  515.           break ;
  516.           }
  517.        default:
  518.           {
  519.           break ;
  520.           }
  521.        }
  522.     return ( DefWindowProc ( hWnd, nMessage, nParam, lParam ) ) ;
  523. }
  524.  
  525.